home *** CD-ROM | disk | FTP | other *** search
- Path: news.eclipse.net!usenet
- From: meritech@eclipse.net
- Newsgroups: comp.lang.c
- Subject: Re: performance of fread
- Date: 26 Jan 1996 17:08:42 GMT
- Message-ID: <4eb1qq$ove@lunar.eclipse.net>
- References: <4eaecp$m5a@zeus.rbi.informatik.uni-frankfurt.de>
- Reply-To: meritech@eclipse.net
- NNTP-Posting-Host: so_69.eclipse.net
- X-Newsreader: IBM NewsReader/2 v1.2
-
- >My question: How time consuming is the overhead of calling fread reading from
- >a large buffer compared to a for( ) loop which takes his data from a memory
- >block which was filled by a single call of fread.
-
- Well. I'll tell you. If this helps. I had the same problem. I had to read in an index
- to a database ( C type structures ), that had over 1000 elements to the index.
- Performing 1000 freads would take way to long, so we swapped out the un-used
- section of memory at the time into XMS, freeing up about 50k of DOS memory in
- the app, allocated the 40k needed to hold the data, and performed one big fread
- into the 40k heap, then, memcpy'd the data into the structure pointer (already allo-
- cated for the 40k), free'd up the 40k buffer, closed the file and reloaded the data
- from XMS into it's right locations.
-
- The optimized process takes about 2 seconds less than the origional code, and the
- profiler shows an almost 25% reduction in code execution for that function, freeing
- up much needed processor time.
-
- The main problem here, is when we attempt to load the 120k record base into xms,
- that damm near takes forever, so we parse load it, 20k initial, when they get 1/2 way
- through the data view, we quickly load another 20k, you notice this on the pgu-pgd
- combo's, but just regular scrolling or searching is fine.
-
- Hope that helps.
-
-